require 'spec_helper'

describe '<%= model_name.camelize.pluralize %>' do
  describe 'GET /v1/<%= model_name.pluralize.underscore %>' do
    describe 'should return <%= model_name.underscore.singularize %> list' do
      before do
        @<%= model_name.underscore.singularize %> = create(:<%= model_name.underscore.singularize %>)
        get '/v1/<%= model_name.pluralize.underscore %>'
      end

      it 'returns 200 success status' do
        expect(response.response_code).to eq 200
      end

      it 'returns a <%= model_name.underscore.singularize %>' do
        expect(json.length).to eq 1
      end

      it 'returns the same <%= model_name.underscore.singularize %>' do
        pending
      end
    end
  end

  describe 'GET /v1/<%= model_name.pluralize.underscore %>/:id' do
    describe 'should return <%= model_name.underscore.singularize %> details' do
      before do
        @<%= model_name.underscore.singularize %> = create(:<%= model_name.underscore.singularize %>)
        get "/v1/<%= model_name.pluralize.underscore %>/#{@<%= model_name.underscore.singularize %>.id}"
      end

      it 'returns 200 success status' do
        expect(response.response_code).to eq 200
      end

      it 'returns a <%= model_name.underscore.singularize %>' do
        pending
      end
    end
  end

  describe 'POST /v1/<%= model_name.pluralize.underscore %>' do
    describe 'should save parameters' do
      before do
        post '/v1/<%= model_name.pluralize.underscore %>'
      end

      it 'returns 201 success status' do
        expect(response.response_code).to eq 201
      end

      it 'saves the <%= model_name.underscore.singularize %>' do
        expect(<%= model_name.camelize.singularize %>.all.count).to eq 1
      end

      it 'saves the <%= model_name.underscore.singularize %> with correct attributes' do
        pending
      end
    end
  end

  describe 'PUT /v1/<%= model_name.pluralize.underscore %>/:id' do
    describe 'should save parameters' do
      before do
        @<%= model_name.underscore.singularize %> = create(:<%= model_name.underscore.singularize %>)
        put "/v1/<%= model_name.pluralize.underscore %>/#{@<%= model_name.underscore.singularize %>.id}"
      end

      it 'returns 200 success status' do
        expect(response.response_code).to eq 200
      end

      it 'updates the <%= model_name.underscore.singularize %>' do
        pending
      end
    end
  end

  describe 'DELETE /v1/<%= model_name.pluralize.underscore %>/:id' do
    describe 'should delete <%= model_name.underscore.singularize %>' do
      before(:each) do
        @<%= model_name.underscore.singularize %> = create(:<%= model_name.underscore.singularize %>)
        delete "/v1/<%= model_name.pluralize.underscore %>/#{@<%= model_name.underscore.singularize %>.id}"
      end

      it 'returns 200 success status' do
        expect(response.response_code).to eq 200
      end

      it 'deletes the <%= model_name.underscore.singularize %>' do
        expect(<%= model_name.camelize.singularize %>.all.count).to eq 0
      end
    end
  end
end
